package org.example.camundaapp.bpm.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.experimental.SuperBuilder;

import java.io.IOException;

/**
 * process流程定义
 * @className: ProcessDefinition
 * @author: ZHRJ
 * @date: 2025-06-25 10:56
 * @Version: 1.0
 * @description:
 */
@Data
@SuperBuilder
@NoArgsConstructor
public class ProcessDefinition {
    private Process process;

    private BaseDefinition processNode;

    public abstract static class ProcessDefinitionBuilder<
            C extends ProcessDefinition, B extends ProcessDefinition.ProcessDefinitionBuilder> {

        public ProcessDefinitionBuilder() {
            process = new Process();
        }

        public B name(String name) {
            process.setName(name);
            return self();
        }

        public B processId(@NonNull String processId) {
            process.setProcessId(processId);
            return self();
        }

        public B processNode(@NonNull BaseDefinition processNode) {
            this.processNode = processNode;
            return self();
        }
    }

   /* public static ProcessDefinition of(String json) {
        ObjectMapper mapper =
                new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        ProcessDefinition result;
        try {
            result = mapper.readValue(json, ProcessDefinition.class);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e.getCause());
        }
        return result;
    }

    @SneakyThrows
    @Override
    public String toString() {
        return new ObjectMapper().writeValueAsString(this);
    }*/
}
